import React, { Component } from "react";

import Child1 from "./Child1";
import Child2 from "./Child2";

class App extends Component {
  state = {
    num: null,
  };

  fn = (n) => {
    console.log("fn", n);
    this.setState({
      num: n,
    });
  };

  render() {
    return (
      <>
        <h2>状态提升 - {this.state.num}</h2>
        {/* 
          做子传父也要在父组件的子组件标签上面添加自定义事件
          不管是属性还是事件都是通过props来接受的
        */}
        <Child1 onAbc={this.fn} />
        <Child2 num={this.state.num} />
      </>
    );
  }
}

export default App;
